//
//  YinDaoViewController.m
//  XiangMu
//
//  Created by 康世标 on 15/9/25.
//  Copyright (c) 2015年 康世标. All rights reserved.
//

#import "YinDaoViewController.h"

@interface YinDaoViewController ()

@end

@implementation YinDaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.scrollView.contentSize = CGSizeMake(kScreenW*3, kScreenH);
    self.scrollView.contentOffset = CGPointMake(0, 0);
    self.scrollView.pagingEnabled = YES;
    self.scrollView.bounces = NO;
    self.scrollView.showsHorizontalScrollIndicator=NO;
  
    NSArray * corlor =@[[UIColor redColor],[UIColor grayColor],[UIColor blueColor]];
    
    NSArray * imageArr =[NSArray arrayWithObjects:@"WeIcome2",@"WeIcome3",@"Welcome1", nil];
    
    for (int i =0; i<3; i++) {
        
        UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW*i, 0, kScreenW, kScreenH)];
        imageView.backgroundColor = [corlor objectAtIndex:i];
        imageView.image = [UIImage imageNamed:[imageArr objectAtIndex:i]];
        imageView.userInteractionEnabled = YES;
        [self.scrollView addSubview:imageView];
        
        if (i==2) {
                   
            UIButton * button =[ UIButton buttonWithType:UIButtonTypeCustom];
         
            [button setTitle:@"开始体验" forState:UIControlStateNormal];
        
            [button.titleLabel setFont:[UIFont systemFontOfSize:16]];
            [button.layer setBorderColor:[UIColor redColor].CGColor];
            [button addTarget:self action:@selector(btnClock:) forControlEvents:UIControlEventTouchUpInside];
            button.backgroundColor = RGBACOLOR(129, 205, 242, 1);
            button.layer.masksToBounds = YES;
            [button.layer setCornerRadius:10];
            
            [imageView addSubview:button];
            
            [button mas_makeConstraints:^(MASConstraintMaker *make) {
//                居中
                make.centerX.equalTo(imageView);
//距离底部
                
                make.bottom.equalTo(imageView).equalTo(@-60);
//                
                make.size.mas_equalTo(CGSizeMake(80, 30));
            }];
            
        }
        
        
    }
    
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
    int x = scrollView.contentOffset.x/kScreenW;
    
    self.page.currentPage = x;
}
- (void)btnClock:(UIButton *)btn{
    NSUserDefaults * use =[NSUserDefaults standardUserDefaults];
    
    [use setObject:@"yindaoye" forKey:@"yindaoye"];
    [use synchronize];
    AppDelegate * app =(AppDelegate *)[UIApplication sharedApplication].delegate;
    
    ViewController * vc = [[ViewController alloc]init];
    app.window.rootViewController = vc;
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
